package Thread_.homework;

public class test7 {
    private static int n;
    //有20个线程，需要同时启动。
    //每个线程按0-19的序号打印，如第一个线程需要打印0
    //请设计代码，在main主线程中，等待所有子线程执行完后，再打印 ok
    public static void main(String[] args) throws InterruptedException {
        Thread t1=new Thread(()->{
            System.out.println(n);
            n++;
        });
        Thread t2=new Thread(()->{
            System.out.println(n);
            n++;
        });
        Thread t3=new Thread(()->{
            System.out.println(n);
            n++;
        });
        Thread t4=new Thread(()->{
            System.out.println(n);
            n++;
        });
        Thread t5=new Thread(()->{
            System.out.println(n);
            n++;
        });
        t1.start();
        t1.join();
        t2.start();
        t2.join();
        t3.start();
        t3.join();
        t4.start();
        t4.join();
        t5.start();
        t5.join();
        System.out.println("ok");
    }
}
